<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class DemoController extends Controller {

    public function index(Request $request) {


        $curl = curl_init();

        curl_setopt_array($curl, array(
            CURLOPT_URL => "https://lp.fxclub.cn/open-account/trade/meta_market/?partner_code=CHN227IPB",
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "POST",
            CURLOPT_POSTFIELDS => "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"email\"\r\n\r\n164925433@qq.com\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\n123456aaa\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"firstname\"\r\n\r\n林\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"lastname\"\r\n\r\n刘\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"city[country]\"\r\n\r\n43\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"city[city]\"\r\n\r\n北京\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"phone1[country_code]\"\r\n\r\n15810882544\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"birthdate[day]\"\r\n\r\n10\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"birthdate[month]\"\r\n\r\n10\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"birthdate[year]\"\r\n\r\n1990\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"form_build_id\"\r\n\r\nform-edloP4Kklwoy2QWQguNkdGicGyD4h8irNoHJg8rvIXU\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"client_timezone\"\r\n\r\n-480\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"acctype\"\r\n\r\nmeta_market\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"form_id\"\r\n\r\nforex_landing_view_form\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"forex_protect_min_time\"\r\n\r\nBa1TNvQM2POqHE8u+drWumev5WtczOxBcGyr2UbkUHc=\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"check_js\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"region_id\"\r\n\r\n\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"captcha_sid\"\r\n\r\n4155669\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"captcha_token\"\r\n\r\n0998e0af2e1b14066cdb50fff5ac19f4\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"captcha_response\"\r\n\r\naemt2\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--",
            CURLOPT_HTTPHEADER => array(
                "cache-control: no-cache",
                "content-type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW",
                "postman-token: 98d83fb5-945e-5d45-7690-bf9fa2864a4a"
            ),
        ));

        $response = curl_exec($curl);
        $err = curl_error($curl);

        curl_close($curl);

        if ($err) {
            echo "cURL Error #:" . $err;
        } else {
            echo $response;
        }
        exit;
//        $url = 'https://lp.fxclub.cn/open-account/trade/meta_market/?partner_code=CHN227IPB';
//        $post_data = array(
//            "email" => "1633878523@qq.com",
//            "password" => "123456aaa",
//            "lastname" => "林",
//            "firstname" => "刘",
//            "city[country]" => "43",
//            "city[city]" => "北京",
//            "phone1[country_code]" => "15810882541",
//            "birthdate[day]" => "1",
//            "birthdate[month]" => "9",
//            "birthdate[year]" => "1990",
//            "captcha_sid" => "4155600",
//            "captcha_token" => "348bf5a8dc2493e9a4fde7340715df9a",
//            "captcha_response" => "dxbfe",
//            "acctype" => "meta_market",
//            "client_timezone" => "-480",
//            "form_build_id" => "form-sZqj8wNyDbijm7LC76_pM94HOBhQvKT8qxuij9-cqyw",
//            "form_id" => "forex_landing_view_form",
//            "form_token" => "null",
//            "forex_protect_min_time" => "5zaIunUhb/G+IyUetV+Lhmev5WtczOxBcGyr2UbkUHc=",
//            "check_js" => "",
//            "region_id" => "",
//        );
//        $pro = $this->postcurl($url, $post_data);
//        print_r($pro);
    }

    /**
     * 导入操作记录
     */
    public function import() {

        $post_data = array(
            "acctype" => "meta_market",
            "client_timezone" => "-480",
            "form_build_id" => "form-ZCMxU32FlEHq7FJTHoHjDS3wpbrZ3CDYrX-HlK9LoO0",
            "form_id" => "forex_landing_view_form",
            "forex_protect_min_time" => "wg8CjWsyApsbPu6pNsMVnmev5WtczOxBcGyr2UbkUHc=",
            "check_js" => "9d8e2bed2118dcb3c102a61adac13f2a45c0fe76form-mCGIe3PSj_-bkdjrAzZ3muoP8ITWohj89zmDxx15iuY",
            "region_id" => "",
            "email" => "1633878522@qq.com",
            "password" => "liu423434545",
            "lastname" => "liu",
            "firstname" => "liu",
            "city[country]" => "43",
            "city[city]" => "北京",
            "phone1[country_code]" => "+8615810882540",
            "birthdate[year]" => "1990",
            "birthdate[month]" => "9",
            "birthdate[day]" => "1",
            "captcha_sid" => "4155496",
            "captcha_token" => "7e6cbe53cd497b6a4c25df910b1a0410",
            "captcha_response" => "m66ee",
            "url" => "",
            'form_token' => 'null',
//            "_token"=> csrf_token()
        );
    }

    public function postcurl($request_url, $data = '') {

        $curl = curl_init();
        curl_setopt($curl, CURLOPT_URL, $request_url);
        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
        curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
        curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1);
        curl_setopt($curl, CURLOPT_POST, true);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
        $output = curl_exec($curl);
        curl_close($curl);
//        $output = json_decode($output, True);

        return $output;
    }

}
